<template>
  <footer class="footer" v-if="list.length > 0">
    <span class="todo-count"
      ><strong>{{ leftConut }}</strong
      >剩余</span
    >
    <ul class="filters">
      <li>
        <a
          href="#/"
          @click.prevent="filter('ken')"
          :class="{ selected: value === 'ken' }"
          >全部</a
        >
      </li>
      <li>
        <a
          href="#/active"
          @click.prevent="filter('active')"
          :class="{ selected: value === 'active' }"
          >进行中</a
        >
      </li>
      <li>
        <a
          href="#/completed"
          @click.prevent="filter('completed')"
          :class="{ selected: value === 'completed' }"
          >已完成</a
        >
      </li>
    </ul>
    <button class="clear-completed" v-show="isShowClear" @click="clear">
      清除已完成
    </button>
  </footer>
</template>
<script>
export default {
  props: {
    list: {
      type: Array,
      required: true,
    },
    list: Array,
    value: String,
  },
  computed: {
    leftConut() {
      return this.list.filter((item) => item.isDone === false).length
    },
    isShowClear() {
      return this.list.some((item) => item.isDone)
    },
  },
  methods: {
    clear() {
      this.$emit('clear')
    },
    filter(type) {
      // this.type = type
      this.$emit('input', type)
    },
  },
  data() {
    return {
      // type: 'ken',
    }
  },
}
</script>
